﻿<%@ Page Language="C#" MasterPageFile="~/Masterpages/Default.master" AutoEventWireup="true"
    CodeBehind="ManageRedirects.aspx.cs" Inherits="Blazing.UI.Cms.Admin.ManageRedirects"
    Title="Manage Redirects" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="System.BusinessObjects.Framework" Namespace="System.BusinessObjects.Controls"
    TagPrefix="cc1" %>
<%@ Register Src="../Usercontrols/Loading.ascx" TagName="Loading" TagPrefix="uc3" %>
<%@ Register Src="../Usercontrols/SelectSite.ascx" TagName="SelectSite" TagPrefix="uc1" %>
<%@ Register Src="../Usercontrols/ChooseSite.ascx" TagName="ChooseSite" TagPrefix="uc2" %>
<%@ Register Src="../Usercontrols/HiddenSite.ascx" TagName="HiddenSite" TagPrefix="uc4" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>
        Manage Url Redirects</h1>
    <uc2:ChooseSite ID="ChooseSite1" runat="server"></uc2:ChooseSite>
    <hr />
    <ajax:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div class="grid">
                <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                    DataKeyNames="ID,RowStamp,RowState" DataSourceID="odsUrlRedirects" Width="100%"
                    EmptyDataText="No Url Redirects were found for this site.">
                    <Columns>
                        <asp:BoundField DataField="MatchPattern" HeaderText="Match Pattern" SortExpression="MatchPattern" />
                        <asp:BoundField DataField="DestinationResult" HeaderText="Destination Result" SortExpression="DestinationResult" />
                        <asp:BoundField DataField="RedirectStatusCode" HeaderText="Redirect Status Code"
                            SortExpression="RedirectStatusCode" />
                        <asp:BoundField DataField="Order" HeaderText="Order" SortExpression="Order" />
                        <asp:CheckBoxField DataField="IsRewrite" HeaderText="Is Rewrite" SortExpression="IsRewrite" />
                        <asp:CheckBoxField DataField="IsHostAppendedAsQueryParam" HeaderText="Host Appended As Query Param"
                            SortExpression="IsHostAppendedAsQueryParam" />
                        <asp:CheckBoxField DataField="IsActive" HeaderText="Is Active" SortExpression="IsActive" />
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                        <asp:TemplateField>
                            <ItemTemplate>
                                <uc4:HiddenSite ID="HiddenSite1" runat="server" CurrentSite='<%# Bind("Site") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </div>
            <asp:ObjectDataSource ID="odsUrlRedirects" runat="server" DataObjectTypeName="Blazing.BusinessObjects.Cms.UrlRedirect"
                DeleteMethod="DeleteUrlRedirect" InsertMethod="NewUrlRedirect" OldValuesParameterFormatString="original_{0}"
                SelectMethod="GetUrlRedirect" SortParameterName="sortExpression" TypeName="Blazing.WebFacade.RedirectController"
                UpdateMethod="UpdateUrlRedirect">
                <SelectParameters>
                    <asp:SessionParameter DefaultValue="-1" Name="siteId" SessionField="siteId" />
                    <asp:Parameter Name="sortExpression" Type="String" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <br />
            <br />
            <asp:LinkButton ID="LinkButtonInsertRedirect" runat="server">Insert</asp:LinkButton>
            <asp:Panel ID="PanelAddRedirect" runat="server" SkinID="PopupPanel1">
                <blazing:RoundedPanel ID="rp1" runat="server" Width="400px">
                    <div class="grid">
                        <div class="gridview">
                            <asp:Panel runat="server" ID="PanelAddRedirectTitle" CssClass="gridheader">
                                Add Redirect</asp:Panel>
                            <asp:DetailsView ID="DetailsViewRedirects" runat="server" AutoGenerateRows="False"
                                DataSourceID="odsUrlRedirects" DefaultMode="Insert">
                                <Fields>
                                    <asp:BoundField DataField="MatchPattern" HeaderText="MatchPattern" SortExpression="MatchPattern" />
                                    <asp:BoundField DataField="DestinationResult" HeaderText="DestinationResult" SortExpression="DestinationResult" />
                                    <asp:BoundField DataField="RedirectStatusCode" HeaderText="RedirectStatusCode" SortExpression="RedirectStatusCode" />
                                    <asp:BoundField DataField="Order" HeaderText="Order" SortExpression="Order" />
                                    <asp:CheckBoxField DataField="IsRewrite" HeaderText="Is Rewrite" SortExpression="IsRewrite" />
                                    <asp:CheckBoxField DataField="IsHostAppendedAsQueryParam" HeaderText="Host Appended As Query Param"
                                        SortExpression="IsHostAppendedAsQueryParam" />
                                    <asp:CheckBoxField DataField="IsActive" HeaderText="Is Active" SortExpression="IsActive" />
                                    <asp:TemplateField>
                                        <InsertItemTemplate>
                                            <uc4:HiddenSite ID="HiddenSite1" runat="server" CurrentSite='<%# Bind("Site") %>' />
                                        </InsertItemTemplate>
                                    </asp:TemplateField>
                                    <asp:CommandField ShowInsertButton="True" />
                                </Fields>
                            </asp:DetailsView>
                        </div>
                    </div>
                </blazing:RoundedPanel>
            </asp:Panel>
            <ajax:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="LinkButtonInsertRedirect"
                PopupControlID="PanelAddRedirect" PopupDragHandleControlID="PanelAddRedirectTitle"
                SkinID="Popup1">
            </ajax:ModalPopupExtender>
        </ContentTemplate>
    </ajax:UpdatePanel>
    <ajax:UpdateProgress runat="server" ID="update" DisplayAfter="50">
        <ProgressTemplate>
            <uc3:Loading ID="Loading1" runat="server" />
        </ProgressTemplate>
    </ajax:UpdateProgress>
    <br />
    <br />
</asp:Content>
